package com.schoolcloud.social.controller.forum;

import com.schoolcloud.common.model.R;
import com.schoolcloud.common.util.UserContext;
import com.schoolcloud.social.entity.SocPostLikes;
import com.schoolcloud.social.service.SocPostLikesService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("social/posts/likes")
@RequiredArgsConstructor
public class SocPostLikeController {
    private final SocPostLikesService socPostLikesService;
    @PostMapping
    public R addLikePost(@RequestBody SocPostLikes socPostLikes){
        socPostLikes.setUserId(Integer.valueOf(UserContext.getUser()));
        socPostLikes.setCreateTime(new Date());
        socPostLikesService.save(socPostLikes);
        return R.ok();
    }
}
